package com.itlong.cloud.enumerate;

import java.util.ArrayList;
import java.util.List;

/**
 * <desc>
 *      物业账号公共角色枚举
 * </desc>
 *
 * @createDate 2017-10-27.
 */
public enum PropertyPublicRoleEnum {

    ADMIN("5","物业管理员"),
    GROUP_ADMIN("3", "集团物业管理员"),
    DEVELOPER("4", "独立开发者"),
    SMART_CARD_DEVELOPER("6", "一卡通开发者"),
    ROBOT_DEVELOPER("7", "机器人开发者"),
    ;

    private String roleId;
    private String roleName;

    PropertyPublicRoleEnum(String roleId, String roleName){
        this.roleId = roleId;
        this.roleName = roleName;
    }

    public String getRoleId() { return roleId; }

    public String getRoleName() { return roleName; }

    /**
     * <desc>
     *      获取角色名称
     * <desc/>
     *
     * @param roleId 角色id
     * @return
     * @author Chunjian.G
     * @createDate 2017-10-31
     */
    public static String getRoleNameByRoleId(String roleId){
        PropertyPublicRoleEnum[] values = PropertyPublicRoleEnum.values();
        for (PropertyPublicRoleEnum value : values){
            if (value.roleId.equals(roleId)){
                return value.roleName;
            }
        }
        return "unknown";
    }

    /**
     * <desc>
     *      获取物业账号公共角色roleId列表
     * <desc/>
     *
     * @return
     * @author Chunjian.G
     * @createDate 2017-10-27
     */
    public static List<String> getPubRoleIdList(){
        PropertyPublicRoleEnum[] values = PropertyPublicRoleEnum.values();
        List<String> roleIds = new ArrayList<>();
        for (PropertyPublicRoleEnum value : values){
            roleIds.add(value.getRoleId());
        }
        return roleIds;
    }

    /**
     * <desc>
     *      物业账号公共角色是否包含某个角色id
     * <desc/>
     *
     * @param roleId 角色id
     * @return
     * @author Chunjian.G
     * @createDate 2017-10-27
     */
    public static boolean containsRoleId(String roleId){
        PropertyPublicRoleEnum[] values = PropertyPublicRoleEnum.values();
        for (PropertyPublicRoleEnum value : values){
            if (value.roleId.equals(roleId)){
                return true;
            }
        }
        return false;
    }
}
